package com.jh.user.repository;

import com.jh.user.pojo.ShopRegister;
import com.jh.user.pojo.TerminalInfo;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

@Repository
public interface TerminalInfoRepository extends JpaRepository<TerminalInfo,String>, JpaSpecificationExecutor<TerminalInfo> {
    TerminalInfo findByMachineNoAndTerminalNo(String machineNo, String terminalNo);

    TerminalInfo findByEvmNoAndTerminalNo(String evmNo, String terminalNo);

    @Modifying
    @Query("delete from TerminalInfo terminalInfo where terminalInfo.shopId=:shopId and terminalInfo.terminalNo=:terminalNo")
    void deleteByShopIdAndTerminalNo(@Param("shopId") String shopId, @Param("terminalNo") String terminalNo);

    ShopRegister findByShopId(String shopId);
}
